#include <cstdio>

int prime[10000];
int prime_size;
bool prime_mark[10001];

void init_prime();

int main(int argc, char const *argv[]){
    init_prime();
    int n;
    while(scanf("%d", &n) != EOF){
        bool first_output = false;
        for (int i = 0; i < prime_size; i++){
            if (prime[i] < n && prime[i] % 10 == 1){
                if (first_output == false){
                    first_output = true;
                    printf("%d", prime[i]);
                }
                else
                    printf(" %d", prime[i]);
            }
        }
        if (first_output == false)
            printf("-1\n");
        else
            printf("\n");
    }
    return 0;
}

void init_prime(){
    for (int i = 0; i <= 10000; i++)
        prime_mark[i] = true;
    prime_size = 0;

    for (int i = 2; i <= 10000; i++){
        if (prime_mark[i] == false)
            continue;
        prime[prime_size++] = i;
        for (int j = i*i; j <= 10000; j += i) // start from i*i not 2*i
            prime_mark[j] = false;
    }
}
